package com.fzy.core.system.service;

import com.fzy.core.utils.SqlUtils;

public class DbServiceFactory {
	public static AbstractDbService getDbService(String driverClassName, String jndiName){
		String dbType = SqlUtils.getDbTypeByDriver(driverClassName);
		if(SqlUtils.DB_H2.equals(dbType))
			return new H2DbService(jndiName);
		else if(SqlUtils.DB_ORACLE.equals(dbType))
			return new OracleDbService(jndiName);
		return null;
	}
	public static AbstractDbService getDbService(String driverClassName, String url, String username,
			String password){
		String dbType = SqlUtils.getDbTypeByDriver(driverClassName);
		if(SqlUtils.DB_H2.equals(dbType))
			return new H2DbService(driverClassName, url, username, password);
		else if(SqlUtils.DB_ORACLE.equals(dbType))
			return new OracleDbService(driverClassName, url, username, password);
		return null;
	}
}
